var app = getApp()
var wxParse = require("../../wxParse/wxParse.js")
Page({
  data: {
    showbtn: false,
    info: {},
    isvoice: false,
    name:""
  },
  onShareAppMessage: function (res) {
    let member_id = app.globalData.userInfo.member_id
    return {
      title: '成纪先锋微平台',
      path: '/pages/news/news_detail?inviter_id=' + member_id,
      success: function (res) {
        // 转发成功
      },
      fail: function (res) {
        // 转发失败
      }
    }
  },
  onReady() {
    this.audioCtx = wx.createAudioContext('myAudio')
  },
  onLoad: function (options) {

    if (options.from == 'news') {
      console.log(options.isstudy)
      if(options.isstudy == 'true'){
        console.log(options.isstudy+"000")
        if (options.id) {
          app.ajax("study_detail", { rd_session: wx.getStorageSync('rd_session'), id: options.id }, (data, err) => {
            wxParse.wxParse("about", "html", data.data.content, this)
            this.setData({
              info: data.data,
              isvoice: false
            })
          })
        }
      }else{
        if (options.id) {
          app.ajax("news_detail", { rd_session: wx.getStorageSync('rd_session'), id: options.id }, (data, err) => {
            wxParse.wxParse("about", "html", data.data.content, this)
            this.setData({
              info: data.data,
              isvoice: false
            })
          })
        }
      }
      
    } else if (options.from == 'guangb') {
      if (options.id) {
        app.ajax("broadcast_site_detail", { rd_session: wx.getStorageSync('rd_session'), id: options.id }, (data, err) => {
          wxParse.wxParse("about", "html", data.data.content, this)
          this.setData({
            info: data.data,
            isvoice:false
          })
        })
      }
    } else if (options.from == 'jiem') {
      app.ajax("broadcast_item_detail", { rd_session: wx.getStorageSync('rd_session'), id: options.id }, (data, err) => {
        this.audioCtx.setSrc(data.data.voice_url)
        this.audioCtx.play()
        wxParse.wxParse("about", "html", data.data.content, this)
        this.setData({
          info: data.data,
          name: data.data.department_name,
          isvoice: true
        })
      })
    } else if (options.from == 'threewei') {
      app.ajax("teach_detail", { rd_session: wx.getStorageSync('rd_session'), id: options.id }, (data, err) => {
        wxParse.wxParse("about", "html", data.data.content, this)
        this.setData({
          info: data.data,
          isvoice: false
        })
      })
    }

  },


});